<?php

/*
 * js_plugin函数
 */
if ( ! function_exists('js_plugin'))
{
	function js_plugin($plugin)
	{
		$plugin = trim($plugin);
		$plugin_string = '';
		$plugin_path = base_url('/themes/plugins');

		$plugins = explode(',', $plugin);
		foreach ($plugins as $plugin)
		{
			$path = rtrim($plugin_path, '/').'/'.trim($plugin);
			$plugin_fun = 'plugin_'.$plugin;
			$need = $plugin_fun();
			$css = $need[0];
			$js = $need[1];
			$str = "\n";
			
			if ($css && is_array($css))
			{
				foreach ($css as $one)
				{
					$str .= '<link rel="stylesheet" href="'.$path.'/'.ltrim($one, '/').'" type="text/css" />'."\n";
				}
			}
			
			if ($js && is_array($js))
			{
				foreach ($js as $one)
				{
					$str .= '<script type="text/javascript" src="'.$path.'/'.ltrim($one, '/').'"></script>'."\n";
				}
			}
			
			$str = "\n".'<!----------'.$plugin.'---------->'.$str;
			$plugin_string .= $str;
		}
		return $plugin_string;
	}
}

/*
 * jquery
 */
if ( ! function_exists('plugin_jquery'))
{
	function plugin_jquery()
	{
		$css = array();
		$js = array('jquery.js');
		return array($css, $js);
	}
}

/*
 * fancybox图片弹出层
 */
if ( ! function_exists('plugin_fancybox'))
{
	function plugin_fancybox()
	{
		$css = array('fancybox.css');
		$js = array(
			'fancybox.js',
			'easing.js',
			'mousewheel.js'
		);
		return array($css, $js);
	}
}

/*
 * colorbox图片弹出层
 */
if ( ! function_exists('plugin_colorbox'))
{
	function plugin_colorbox()
	{
		$css = array('colorbox.css');
		$js = array(
			'colorbox.js'
		);
		return array($css, $js);
	}
}

/*
 * datepicker日期选择框
 */
if ( ! function_exists('plugin_datepicker'))
{
	function plugin_datepicker()
	{
		$css = array('datepicker.css');
		$js = array('datepicker.js');
		return array($css, $js);
	}
}

/*
 * colorpicker颜色选择框
 */
if ( ! function_exists('plugin_colorpicker'))
{
	function plugin_colorpicker()
	{
		$css = array('colorpicker.css');
		$js = array('colorpicker.js');
		return array($css, $js);
	}
}

/*
 * lazyload图片延迟加载
 */
if ( ! function_exists('plugin_lazyload'))
{
	function plugin_lazyload()
	{
		$css = array();
		$js = array('lazyload.js');
		return array($css, $js);
	}
}

/*
 * jcrop图片裁剪
 */
if ( ! function_exists('plugin_jcrop'))
{
	function plugin_jcrop()
	{
		$css = array('jcrop');
		$js = array('jcrop.js');
		return array($css, $js);
	}
}

/*
 * share分享按钮
 */
if ( ! function_exists('plugin_share'))
{
	function plugin_share()
	{
		$css = array();
		$js = array('share.js');
		return array($css, $js);
	}
}